import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class LunchPage extends StatefulWidget {
  @override
  _LunchPageState createState() => _LunchPageState();
}

class _LunchPageState extends State<LunchPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('url_launch'),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            RaisedButton(
              onPressed: _lanuer,
              child: Text('打开浏览器'),
            ),
            RaisedButton(
              onPressed: _openMap,
              child: Text('打开地图'),
            ),
          ],
        ),
      ),
    );
  }
  _lanuer() async{
    const String url = 'https://www.baidu.com';
    if (await canLaunch(url)) {
      launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }
  _openMap() async {
    const String url = 'geo:52.32.4.917';
    if (await canLaunch(url)) {
      launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }
}
